package cn.ekuma.epos.analysis.customer;

import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;

import javax.swing.JToolBar;

import cn.ekuma.data.dao.I_ParentNode;
import cn.ekuma.data.dao.bean.IKeyed;
import cn.ekuma.data.dao.bean.I_ViewBean;
import cn.ekuma.data.ui.swing.AbstractDAOJEditor;
import cn.ekuma.data.ui.swing.ParentNodeChangeListener;
import cn.ekuma.data.ui.swing.dnd.BeanListTransferable;
import cn.ekuma.epos.analysis.customer.model.CustomerAnalysisTableModel;
import cn.ekuma.epos.customerfinishing.model.CustomerTableModel;
import cn.ekuma.epos.datalogic.I_DataLogicERP;
import cn.ekuma.epos.datalogic.define.dao.erp.CustomerAnalysisInfoDAO;
import cn.ekuma.epos.db.table.I_Customer;
import cn.ekuma.epos.module.ERP_UI_Swing_Model;
import cn.ekuma.rabbit.spi.I_ModelPart;

import com.openbravo.bean.Customer;
import com.openbravo.bean.CustomerCategory;
import com.openbravo.bean.Product;
import com.openbravo.bean.erp.OperationCustomerCategory;
import com.openbravo.beans.JCalendarDialog;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.gui.MessageInf;
import com.openbravo.data.loader.query.QBFCompareEnum;
import com.openbravo.data.loader.query.QBFParameter;
import com.openbravo.data.loader.query.QBFParameters;
import com.openbravo.data.loader.ui.JQBFParametersPanel;
import com.openbravo.data.user.EditorCreator;
import com.openbravo.format.Formats;
import com.openbravo.pos.base.AppLocal;
import com.openbravo.pos.base.AppView;
import com.openbravo.pos.base.BeanFactoryApp;
import com.openbravo.pos.base.BeanFactoryException;
import com.openbravo.pos.base.I_AppView;
import com.openbravo.pos.forms.JPanelView;
import com.openbravo.pos.panels.QuickTimerFilter;
import com.openbravo.pos.panels.event.CustomerCategoryChangedListener;
import com.openbravo.pos.panels.event.TimeCycleChangedEvent;
import com.openbravo.pos.panels.event.TimeCycleChangedListener;
import com.openbravo.pos.panels.navigator.JCustomerCategoryNavigator;
import com.openbravo.pos.panels.navigator.JOperationCustomerCategoryNavigator;
import com.openbravo.pos.panels.navigator.event.OperationCustomerCategoryChangedListener;
import javax.swing.BoxLayout;
import java.awt.Container;
import javax.swing.JTextField;
import java.awt.Dimension;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.ListSelectionModel;
import net.sourceforge.jtimepiece.TimeUtil;
import org.jdesktop.swingx.JXTable;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.JSplitPane;
import java.awt.GridBagLayout;

public class JCustomerAnalysisPanel extends JPanel implements JPanelView,
		BeanFactoryApp, EditorCreator, TimeCycleChangedListener,ListSelectionListener,DragGestureListener, // For recognizing the start of drags
		DragSourceListener,I_ModelPart<ERP_UI_Swing_Model> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 8842624968131384340L;
	private JTextField textField;
	private JTextField textField_1;
	private JToolBar jToolBar1;
	private QuickTimerFilter timerFilter;
	private JLabel jLabel3;
	private JTextField jTxtStartDate;
	private JButton btnDateStart;
	private JLabel jLabel4;
	private JTextField jTxtEndDate;
	private JButton btnDateEnd;
	private JButton jButton1;
	private JPanel jNavigator;
	private Container jNavigatorToolBar;
	private JButton btnNewButton;
	private JButton button;
	private JPanel panel_1;
	private JTextField inputCode;
	private JButton button_3;
	private JButton button_2;
	private CardLayout cl1;
	private JXTable jXTable1;

	protected I_DataLogicERP dlSales;
	private Object[] beforeFilterParas;
	private JCustomerCategoryNavigator customerCategoryNavigator;
	private JOperationCustomerCategoryNavigator operationCustomerCategoryNavigator;
	private JScrollPane scrollPane;
	private JButton btnNewButton_4;
	private JTabbedPane linkTabPanel;
	private JSplitPane splitPane;
	private JPanel panel_2;
	private JPanel panel_3;
	protected String customerID;
	
	AnalysisModelManager manager;
	
	QBFParameter customer_card=new QBFParameter(CustomerAnalysisInfoDAO.PREF_CUSTOMER+I_Customer.CARD);
	QBFParameter customer_city=new QBFParameter(CustomerAnalysisInfoDAO.PREF_CUSTOMER+I_Customer.CITY);
	QBFParameter customer_POSTAL=new QBFParameter(CustomerAnalysisInfoDAO.PREF_CUSTOMER+I_Customer.POSTAL);
	QBFParameter customer_NAME=new QBFParameter(CustomerAnalysisInfoDAO.PREF_CUSTOMER+I_Customer.NAME1);
	QBFParameter customer_SEARCHKEY=new QBFParameter(CustomerAnalysisInfoDAO.PREF_CUSTOMER+I_Customer.SEARCHKEY);
	QBFParameter customer_REGION=new QBFParameter(CustomerAnalysisInfoDAO.PREF_CUSTOMER+I_Customer.REGION);
	QBFParameter customer_COUNTRY=new QBFParameter(CustomerAnalysisInfoDAO.PREF_CUSTOMER+I_Customer.COUNTRY);
	
	QBFParameter customer_CATEGORY=new QBFParameter(CustomerAnalysisInfoDAO.PREF_CUSTOMER+I_Customer.CATEGORY);
	
	QBFParameter transation_startTime=new QBFParameter("T.CURDATE");
	QBFParameter transation_endTime=new QBFParameter("T.CURDATE");
	
	QBFParameter transation_OPERATION_CUSTOMER_CATEGORIES=new QBFParameter("OPC.ID");
	
	/**
	 * Create the panel.
	 */
	public JCustomerAnalysisPanel() {
		initComponents();
		DragSource dragSource = DragSource.getDefaultDragSource();
	    dragSource.createDefaultDragGestureRecognizer(jXTable1,
	        DnDConstants.ACTION_COPY_OR_MOVE, this);
	}

	private void initComponents() {
		setLayout(new BorderLayout(0, 0));

		JPanel panel = new JPanel();
		add(panel, BorderLayout.NORTH);
		panel.setLayout(new BorderLayout(0, 0));

		jToolBar1 = new javax.swing.JToolBar();
		panel.add(jToolBar1, BorderLayout.NORTH);

		timerFilter = new QuickTimerFilter();
		panel.add(timerFilter, BorderLayout.CENTER);
		timerFilter.addTimeCycleChangedListener(this);
		jLabel3 = new javax.swing.JLabel();
		jTxtStartDate = new javax.swing.JTextField();
		btnDateStart = new javax.swing.JButton();
		jLabel4 = new javax.swing.JLabel();
		jTxtEndDate = new javax.swing.JTextField();
		btnDateEnd = new javax.swing.JButton();
		jButton1 = new javax.swing.JButton();

		jToolBar1.setRollover(true);

		jLabel3.setText(AppLocal.getIntString("Label.StartDate")); // NOI18N
		jToolBar1.add(jLabel3);

		jTxtStartDate.setMinimumSize(new java.awt.Dimension(6, 15));
		jTxtStartDate.setPreferredSize(new java.awt.Dimension(150, 22));
		jToolBar1.add(jTxtStartDate);

		btnDateStart.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/com/openbravo/images/date.png"))); // NOI18N
		btnDateStart.setFocusable(false);
		btnDateStart
				.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		btnDateStart.setPreferredSize(new java.awt.Dimension(55, 25));
		btnDateStart.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		btnDateStart.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btnDateStartActionPerformed(evt);
			}
		});
		jToolBar1.add(btnDateStart);

		jLabel4.setText(AppLocal.getIntString("Label.EndDate")); // NOI18N
		jToolBar1.add(jLabel4);

		jTxtEndDate.setPreferredSize(new java.awt.Dimension(150, 22));
		jToolBar1.add(jTxtEndDate);

		btnDateEnd.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/com/openbravo/images/date.png"))); // NOI18N
		btnDateEnd.setFocusable(false);
		btnDateEnd.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		btnDateEnd.setPreferredSize(new java.awt.Dimension(55, 25));
		btnDateEnd.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		btnDateEnd.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				btnDateEndActionPerformed(evt);
			}
		});
		jToolBar1.add(btnDateEnd);

		jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/com/openbravo/images/1rightarrow.png"))); // NOI18N
		jButton1.setFocusable(false);
		jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButton1.setPreferredSize(new java.awt.Dimension(55, 25));
		jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButton1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton1ActionPerformed(evt);
			}
		});
		jToolBar1.add(jButton1);
		
		btnNewButton_4 = new JButton("");
		btnNewButton_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				m_jResert1ActionPerformed(e);
				
			}
		});
		btnNewButton_4.setIcon(new ImageIcon(JCustomerAnalysisPanel.class.getResource("/com/openbravo/images/reload.png")));
		jToolBar1.add(btnNewButton_4);

		jNavigatorToolBar = new JPanel();
		panel.add(jNavigatorToolBar, BorderLayout.EAST);
		jNavigatorToolBar.setLayout(new BoxLayout(jNavigatorToolBar,
				BoxLayout.LINE_AXIS));

		button = new JButton(new javax.swing.ImageIcon(getClass().getResource(
				"/com/openbravo/images/search.png")));
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				jNavigator.setVisible(!jNavigator.isVisible());
				if(jNavigator.isVisible()){
					cl1.show(jNavigator, "QBFPanel");
				}
			}
		});

		panel_1 = new JPanel();
		jNavigatorToolBar.add(panel_1);

		inputCode = new JTextField();
		inputCode.setPreferredSize(new Dimension(120, 21));
		panel_1.add(inputCode);

		button_3 = new JButton(new ImageIcon(
				JCustomerAnalysisPanel.class
						.getResource("/com/openbravo/images/apply.png")));
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				m_jBarcode1ActionPerformed(e);
			}
		});
		panel_1.add(button_3);

		jNavigatorToolBar.add(button);

		button_2 = new JButton(AppLocal.getIntString("Menu.CustomerCategories"));
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				cl1.show(jNavigator, "category");
			}
		});
		jNavigatorToolBar.add(button_2);

		btnNewButton = new JButton(
				AppLocal.getIntString("label.operationCustomerCategory"));
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				cl1.show(jNavigator, "operationCategory");
			}
		});
		jNavigatorToolBar.add(btnNewButton);

		jNavigator = new JPanel();
		jNavigator.setPreferredSize(new Dimension(240, 10));
		add(jNavigator, BorderLayout.EAST);
		jNavigator.setLayout(new CardLayout(0, 0));
		
		panel_3 = new JPanel();
		jNavigator.add(panel_3, "QBFPanel");
		panel_3.setLayout(new BorderLayout(0, 0));
		
		panel_2 = new JPanel();
		panel_2.setPreferredSize(new Dimension(10, 155));
		panel_3.add(panel_2, BorderLayout.NORTH);
		GridBagLayout gbl_panel_2 = new GridBagLayout();
		gbl_panel_2.columnWidths = new int[]{120, 120, 0};
		gbl_panel_2.rowHeights = new int[]{31, 31, 31, 0};
		gbl_panel_2.columnWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
		gbl_panel_2.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
		panel_2.setLayout(gbl_panel_2);
		
		splitPane = new JSplitPane();
		splitPane.setOneTouchExpandable(true);
		splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
		add(splitPane, BorderLayout.CENTER);
		
		scrollPane = new JScrollPane();
		splitPane.setLeftComponent(scrollPane);

		jXTable1 = new JXTable();
		jXTable1.setColumnControlVisible(true);
	     jXTable1.setAutoCreateRowSorter(true);
	     jXTable1.setAutoResizeMode(JXTable.AUTO_RESIZE_OFF);
	     jXTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	     scrollPane.setViewportView(jXTable1);
		
		linkTabPanel = new JTabbedPane(JTabbedPane.TOP);
		splitPane.setRightComponent(linkTabPanel);
		splitPane.setDividerLocation(500);
	}


	protected void m_jResert1ActionPerformed(ActionEvent e) {
		beforeFilterParas=null;
		timerFilter.resert();
		jTxtStartDate.setText(null);
		jTxtEndDate.setText(null);
		
		inputCode.setText(null);
		customer_card.clear();
	    customer_city.clear();
	    customer_POSTAL.clear();
	    customer_NAME.clear();
	    customer_COUNTRY.clear();
	    customer_city.clear();
	    customer_SEARCHKEY.clear();
	    customer_REGION.clear();
	    
	    customer_CATEGORY.clear();
		transation_OPERATION_CUSTOMER_CATEGORIES.clear();
	}


	protected void m_jBarcode1ActionPerformed(ActionEvent e) {
		String sCode = inputCode.getText();
		if (sCode.isEmpty()) {
			customer_card.clear();
		    customer_city.clear();
		    customer_POSTAL.clear();
		    customer_NAME.clear();
		    customer_COUNTRY.clear();
		    customer_city.clear();
		    customer_SEARCHKEY.clear();
		    customer_REGION.clear();
			return;
		}else{
			customer_card.equal(sCode);
		    customer_city.equal(sCode);
		    customer_POSTAL.equal(sCode);
		    customer_NAME.link(sCode);
		    customer_COUNTRY.equal(sCode);
		    customer_city.equal(sCode);
		    customer_SEARCHKEY.link(sCode);
		    customer_REGION.equal(sCode);
		}
		jButton1ActionPerformed(e);
	}

	protected void jButton1ActionPerformed(ActionEvent evt) {
		try {
			beforeFilterParas = (Object[]) createValue();
			reQuery();
		} catch (BasicException e) {
			new MessageInf(e).show(this);
		}
	}

	private void reQuery() {
		
			transation_startTime.setQbf((QBFCompareEnum) beforeFilterParas[0]);
			transation_startTime.setValue(beforeFilterParas[1]);
			transation_endTime.setQbf((QBFCompareEnum) beforeFilterParas[2]);
			transation_endTime.setValue(beforeFilterParas[3]);
			
			
			QBFParameters analysisparas=new QBFParameters();
			analysisparas.or(this.customer_card)
			     .or(this.customer_city)
			     .or(this.customer_POSTAL)
			     .or(this.customer_NAME)
			     .or(this.customer_COUNTRY)
			     .or(this.customer_city)
			     .or(this.customer_SEARCHKEY)
			     .or(this.customer_REGION)
			     .and(customer_CATEGORY)
			     .and(transation_OPERATION_CUSTOMER_CATEGORIES);
			
			
			QBFParameters transactionParas=new QBFParameters();
			transactionParas.or(this.customer_card)
		     .or(this.customer_city)
		     .or(this.customer_POSTAL)
		     .or(this.customer_NAME)
		     .or(this.customer_COUNTRY)
		     .or(this.customer_city)
		     .or(this.customer_SEARCHKEY)
		     .or(this.customer_REGION)
		     .and(transation_startTime)
		     .and(transation_endTime)
		     .and(customer_CATEGORY)
		     .and(transation_OPERATION_CUSTOMER_CATEGORIES);
			
			try {
			manager.query(analysisparas, transactionParas);
			
			if (beforeFilterParas[1] != null){
				jTxtStartDate.setText(Formats.TIMESTAMP
						.formatValue(beforeFilterParas[1]));
			}else{
				jTxtStartDate.setText(null);
			}if (beforeFilterParas[3] != null){
				jTxtEndDate.setText(Formats.TIMESTAMP
						.formatValue(beforeFilterParas[3]));
			}else{
				jTxtEndDate.setText(null);
			}
		} catch (BasicException ex) {
			new MessageInf(ex).show(this);
		}
	}

	private void btnDateStartActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnDateStartActionPerformed
		Date date;
		try {
			date = (Date) Formats.TIMESTAMP.parseValue(jTxtStartDate.getText());
		} catch (BasicException e) {
			date = null;
		}
		date = JCalendarDialog.showCalendarTimeHours(this, date);
		if (date != null) {
			jTxtStartDate.setText(Formats.TIMESTAMP.formatValue(date));
		}
	}// GEN-LAST:event_btnDateStartActionPerformed

	private void btnDateEndActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnDateEndActionPerformed
		Date date;
		try {
			date = (Date) Formats.TIMESTAMP.parseValue(jTxtEndDate.getText());
		} catch (BasicException e) {
			date = null;
		}
		date = JCalendarDialog.showCalendarTimeHours(this, date);
		if (date != null) {
			jTxtEndDate.setText(Formats.TIMESTAMP.formatValue(date));
		}
	}// GEN-LAST:event_btnDateEndActionPerformed

	@Override
	public Object createValue() throws BasicException {
		Object[] afilter = new Object[6];

		// Date range
		Object startdate = Formats.TIMESTAMP
				.parseValue(jTxtStartDate.getText());
		Object enddate = Formats.TIMESTAMP.parseValue(jTxtEndDate.getText());

		afilter[0] = (startdate == null) ? QBFCompareEnum.COMP_NONE
				: QBFCompareEnum.COMP_GREATEROREQUALS;
		afilter[1] = startdate;
		afilter[2] = (enddate == null) ? QBFCompareEnum.COMP_NONE
				: QBFCompareEnum.COMP_LESS;
		afilter[3] = enddate;

		//category
		afilter[4] = QBFCompareEnum.COMP_NONE;
		afilter[5] = null;
		
		return afilter;
	}

	@Override
	public String getTitle() {
		return null;//AppLocal.getIntString("Menu.ProdcutFinishing");
	}

	@Override
	public void activate() throws BasicException {
        customerCategoryNavigator.loadData();
        operationCustomerCategoryNavigator.loadData();
	}

	@Override
	public boolean deactivate() {
		return true;
	}

	@Override
	public JComponent getComponent() {
		return this;
	}

	@Override
	public Object getBean() {
		return this;
	}

	@Override
	public void init(I_AppView app) throws BeanFactoryException {
		cl1 = (CardLayout) (jNavigator.getLayout());
		jNavigator.setVisible(false);
		manager=new AnalysisModelManager(dlSales);
		jXTable1.setModel(manager.getTableModel());
		jXTable1.getSelectionModel().addListSelectionListener(this);
		customerCategoryNavigator = new JCustomerCategoryNavigator(dlSales);
		customerCategoryNavigator.addCustomerCategoryChangedListener(new CustomerCategoryChangedListener(){

			@Override
			public void valueSelectChanged(CustomerCategory obj) {
				if (beforeFilterParas == null)
					try {
						beforeFilterParas = (Object[]) createValue();
					} catch (BasicException e) {
						new MessageInf(e).show(JCustomerAnalysisPanel.this);
						return;
					}
					
					transation_OPERATION_CUSTOMER_CATEGORIES.clear();
					
					// Categoria
					customer_CATEGORY.setQbf(QBFCompareEnum.COMP_EQUALS);
					customer_CATEGORY.setValue(obj.getID());
					
					reQuery();
			}
			
		});
		jNavigator.add(customerCategoryNavigator, "category");

		operationCustomerCategoryNavigator = new JOperationCustomerCategoryNavigator(
				dlSales);
		operationCustomerCategoryNavigator.addOperationCustomerCategoryChangedListener
				(new OperationCustomerCategoryChangedListener(){

					@Override
					public void valueSelectChanged(OperationCustomerCategory obj) {

						if (beforeFilterParas == null)
							try {
								beforeFilterParas = (Object[]) createValue();
							} catch (BasicException e) {
								new MessageInf(e).show(JCustomerAnalysisPanel.this);
								return;
							}
							
							customer_CATEGORY.clear();
							// Categoria
							transation_OPERATION_CUSTOMER_CATEGORIES.setQbf(QBFCompareEnum.COMP_EQUALS);
							transation_OPERATION_CUSTOMER_CATEGORIES.setValue(obj.getID());
							
							reQuery();
						
					}
					
				});
		jNavigator.add(operationCustomerCategoryNavigator, "operationCategory");
		
        
        //linkTabPanel.add(AppLocal.getIntString("Menu.Categories"),new JDropProductByCategoryPanel(dlSales));
        //linkTabPanel.add(AppLocal.getIntString("label.operationProductCategory"),new JDropProductByOperationCategoryPanel(dlSales));
        
        JQBFParametersPanel qbfPanel=new JQBFParametersPanel(){

			@Override
			public void doQBFParametersFilter(QBFParameters paras) {
				/**try {
					tableModel.resert(dlSales.query(Customer.class, paras));
				} catch (BasicException e) {
					new MessageInf(e).show(this);
				}**/
			}
        };
        qbfPanel.setShowFieldCount(6);
        qbfPanel.setFields(CustomerTableModel.getQBFFields());
        panel_3.add(qbfPanel, BorderLayout.CENTER);
        
               
        linkTabPanel.addChangeListener(new ChangeListener(){
            
			@Override
            public void stateChanged(ChangeEvent e) {
                fireCustomerChanged(customerID,null);
            }
        });
  	}

	protected void fireCustomerChanged(String productID2, Object object) {
		   
	}

	public final void addObjectChangeListener(ParentNodeChangeListener<Product> l) {
        listenerList.add(ParentNodeChangeListener.class,l);
    }

    public final void removeListDataListener(ParentNodeChangeListener<Product> l) {
    	listenerList.remove(ParentNodeChangeListener.class,l);
    }

	@Override
	public void valueChanged(ListSelectionEvent e) {
		/**int selectedRow=jXTable1.getSelectedRow();
	    if(selectedRow>=0){
	    	final Customer obj=tableModel.getObj(jXTable1.convertRowIndexToModel(selectedRow));
	    	I_ParentNode parent=new I_ParentNode(){

				@Override
				public IKeyed getParentKey() {
					return obj;
				}
				@Override
				public Class getParentClass() {	
					return Product.class;
				}
        	  };
	          for(ObjectChangeListener l:listenerList.getListeners(ObjectChangeListener.class))
	        	  l.valueChange(AbstractDAOJEditor.STATE_Edit,parent);
	          
	          fireCustomerChanged(obj.getId(), obj);
	    }**/
	}

	@Override
	public void dragEnter(DragSourceDragEvent dsde) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dragOver(DragSourceDragEvent dsde) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dropActionChanged(DragSourceDragEvent dsde) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dragExit(DragSourceEvent dse) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dragDropEnd(DragSourceDropEvent dsde) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dragGestureRecognized(DragGestureEvent dge) {
		/**int[] selectedRows=jXTable1.getSelectedRows();
        List<I_ViewBean> rows=new ArrayList();
        for(int i=0;i<selectedRows.length;i++){
            rows.add((Customer) tableModel.getObj(jXTable1.convertRowIndexToModel(selectedRows[i])));
        }
	    Transferable transferable = null;
	    transferable=new BeanListTransferable(rows);
	    dge.startDrag(null, transferable, this);
		**/
	}

	@Override
	public void timeCycleChanged(TimeCycleChangedEvent e) {
		if (beforeFilterParas == null)
			try {
				beforeFilterParas = (Object[]) createValue();
			} catch (BasicException ex) {
				new MessageInf(ex).show(this);
				return;
			}
			// Date range
			Object startdate = e.getStartDate();
			Object enddate = e.getEndDate();

			beforeFilterParas[0] = (startdate == null) ? QBFCompareEnum.COMP_NONE
					: QBFCompareEnum.COMP_GREATEROREQUALS;
			beforeFilterParas[1] = startdate;
			beforeFilterParas[2] = (enddate == null) ? QBFCompareEnum.COMP_NONE
					: QBFCompareEnum.COMP_LESS;
			beforeFilterParas[3] = enddate;
			reQuery();
	}

	@Override
	public String getModelName() {
		return ERP_UI_Swing_Model.MODEL_NAME;
	}

	@Override
	public void setModel(ERP_UI_Swing_Model mode) {
		this.dlSales=mode.getDLERP();
		
	}

}
